package com.peng.access;

import com.peng.pojo.LoginUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("dp")
public class DPExpressionRoot {
    public boolean hasAuthority(String value){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        LoginUser loginUser  = (LoginUser) authentication.getPrincipal();
        List<String> permissions = loginUser.getPermissions();
        return permissions.contains(value);
    }
}
